public class HomePageApprovalItem
{
     public List<ProcessInstanceWorkitem > ProcessList{get;set;}
     public List<HomePageApprovalEntry> ApprovalEntryList{get;set;}
     
     public String ActivityObjectPrefix{get;set;}
     public String OrderObjectPrefix{get;set;}
     public String CheckInventoryObjectPrefix{get;set;}
     
    public HomePageApprovalItem()
    {
         ActivityObjectPrefix= Participator_Detail_Area__c.sObjectType.getDescribe().getKeyPrefix();   
         OrderObjectPrefix=Order__c.sObjectType.getDescribe().getKeyPrefix();
         CheckInventoryObjectPrefix=CheckInventory__c.sObjectType.getDescribe().getKeyPrefix();
         
        ProcessList=[Select ProcessInstance.Status, ProcessInstance.TargetObjectId, ProcessInstance.Id, ProcessInstanceId,
         Id,CREATEDDATE,CREATEDBYID
         From ProcessInstanceWorkitem where ProcessInstance.Status='Pending' and ACTORID=:UserInfo.getUserId()];
         List<Id> idList=new List<Id>();
         for(ProcessInstanceWorkitem items:ProcessList)
         {
             if(String.valueof(items.ProcessInstance.TargetObjectId).substring(0,3) == ActivityObjectPrefix)
                 idList.add(items.ProcessInstance.TargetObjectId);
         }
         map<Id,Participator_Detail_Area__c> pdaList=new map<Id,Participator_Detail_Area__c> ([select Activity_Information__r.Name from  Participator_Detail_Area__c where Id in:idList]);
         
         ApprovalEntryList=new List<HomePageApprovalEntry>();
         for(ProcessInstanceWorkitem items:ProcessList)
         {
             string typeString='';
             if(String.valueof(items.ProcessInstance.TargetObjectId).substring(0,3) == ActivityObjectPrefix)
                 typeString='活动';
             if(String.valueof(items.ProcessInstance.TargetObjectId).substring(0,3) == OrderObjectPrefix)
                 typeString='订单';
              if(String.valueof(items.ProcessInstance.TargetObjectId).substring(0,3) == CheckInventoryObjectPrefix)
                  typeString='库存盘点';    
             
              Participator_Detail_Area__c pda=pdaList.get(items.ProcessInstance.TargetObjectId);
              HomePageApprovalEntry entry=new HomePageApprovalEntry();
              entry.ProcessId=items.Id;
              entry.TargetObjectId=items.ProcessInstance.TargetObjectId;
              if(pda!=NULL)
                  entry.TargetName=pda.Activity_Information__r.Name;
              else
                  entry.TargetName=items.ProcessInstance.TargetObjectId;
             
              entry.ApprovalType=typeString;
              entry.CreatedById=items.CREATEDBYID;
              entry.CreatedDate=items.CREATEDDATE;
              ApprovalEntryList.add(entry);
         }
    }
  
}